package com.ruoyi.sysem.controller;

import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.sysem.domain.BorrowUser;
import com.ruoyi.sysem.domain.from.LoginUser;
import com.ruoyi.sysem.service.UserService;
import com.ruoyi.sysem.util.ResultObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
//@CrossOrigin
@RequestMapping("/user/cuser")
public class UserController  extends BaseController {


    @Autowired
    UserService userService;


    @PostMapping("/login")
    public ResultObject<Map> login(@RequestBody LoginUser loginUser){
        return userService.login(loginUser);
    }

    @GetMapping("/Uidlist")
    public TableDataInfo list(BorrowUser borrowUser)
    {
        List<BorrowUser> list = userService.selectUserList(borrowUser);
        return getDataTable(list);
    }

    /**
     * 修改借款用户授信资料
     */
    @PutMapping("/updateUser")
    public AjaxResult updateUser(@RequestBody BorrowUser borrowUser)
    {
        return toAjax(userService.updateUser(borrowUser));
    }
}
